{extend name="base" /}
{block name="body"}
<div class="layui-card">
    <div class="layui-card-body">
        <form action="{:request()->url()}" class="layui-form" method="post">
            {if request()->action() == 'add'}
            <div class="layui-form-item">
                <label class="layui-form-label">下次回访</label>
                <div class="layui-input-inline">
                    <input type="checkbox" name="is_next" title="设定回访时间" lay-filter="datetime">
                </div>
                <div class="layui-input-inline">
                    <input type="text" id="datetime" name="datetime" value="{$data.datetime|default=''}" id="datetime" autocomplete="off" class="layui-input">
                </div>
            </div>
            {/if}
            {foreach name="field" item="r"}
            <div class="layui-form-item">
                <label class="layui-form-label {if $r.is_required == '1'}layui-form-required{/if}">{$r.title}</label>
                <div class="layui-input-block">
                    {if isset($data)}
                        {:get_code($r,$data)}
                    {else}
                        {:get_code($r)}
                    {/if}
                </div>
            </div>
            {/foreach}
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-filter="i" lay-submit="">保存</button>
                    <button class="layui-btn layui-btn-primary" type="reset">重置</button>
                </div>
            </div>
        </form>
    </div>
</div>
{/block}
{block name="js"}
    {foreach name="field" item="r"}
        {:get_code_js($r)}
    {/foreach}
    <script type="text/javascript">
        $('#datetime').hide();
        form.on('checkbox(datetime)', function(data){
            if(data.elem.checked == true){
                $('#datetime').show();
            }else{
                $('#datetime').hide();
            }
        });
        <?php $today = date('Y-m-d',time());?>
        laydate.render({
            elem: '#datetime'
            ,min: '{$today}'
            ,max: '2080-12-31'
        });

    </script>
{/block}